Reset password

Press e to edit the grub

Ubuntu, Debian

  • When root has no password:
    • select receovery mode
    • select root user
      • then you will be droped into busybox with root access
  • When root has a password:
    • Add init=/bin/bash to linux line
    • mount -o remount,rw /
    • passwd
    • reboot

Redhat, CentOs, Fedora

  • Add to linux16 line:
    • rd.break
    • enforcing=0

ctrl+x to boot it will drop us to ramdisk

In [ ]:
mount -o rw,remount /sysroot
In [ ]:
chroot /sysroot
In [ ]:
passwd
In [ ]:
exit
In [ ]:
mount -o ro,remount /sysroot
In [ ]:
exit
In [ ]:
restorecon /etc/shadow
In [ ]:
setenforce 1

Lecture notes

License

Creative Commons License

Linux Notes by Milad As (Ravexina) is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.


ravexina's gitlab

ravexina's github